package department.fc.controller;

import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import department.fc.common.AttributeAndView;
import department.fc.common.Controller;
//부서 수정 폼 처리 요청??
import department.fc.domain.Department;
import department.fc.service.DepartmentService;

public class ModifyDepartmentFormController implements Controller{

	@Override
	public AttributeAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		int departmentNum = Integer.parseInt(request.getParameter("departmentNum"));
		
		
		DepartmentService service = DepartmentService.getInstance();
		AttributeAndView av = null;
		//비즈니스 로직 처리 
		try{
			Department department = service.getDepartmentByNum(departmentNum);
			av = new AttributeAndView(false, "/WEB-INF/jsp/dept/department_detail.jsp", "department", department);
		}catch(SQLException e){
			e.printStackTrace();
			av = new AttributeAndView(false, "/WEB-INF/jsp/error.jsp", "error_message", e.getMessage());
		}
		return av;
	}
}
